home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / fsrmt / fsrmtOps.c < prev    next >
C/C++ Source or Header  |  1990-10-10  |  6KB  |  217 lines

  1. /* 
  2.  * fsRmtOps.c --
  3.  *
  4.  *    Routine for initializing the fsOpTable switch entries for remote
  5.  *    domain naming and remote file/pipe/device access.
  6.  *
  7.  * Copyright 1989 Regents of the University of California
  8.  * Permission to use, copy, modify, and distribute this
  9.  * software and its documentation for any purpose and without
  10.  * fee is hereby granted, provided that the above copyright
  11.  * notice appear in all copies.  The University of California
  12.  * makes no representations about the suitability of this
  13.  * software for any purpose.  It is provided "as is" without
  14.  * express or implied warranty.
  15.  */
  16.  
  17. #ifndef lint
  18. static char rcsid[] = "$Header: /sprite/src/kernel/fsrmt/RCS/fsrmtOps.c,v 9.4 90/10/08 15:07:26 mendel Exp $ SPRITE (Berkeley)";
  19. #endif /* not lint */
  20.  
  21. #include <sprite.h>
  22. #include <fs.h>
  23. #include <fsconsist.h>
  24. #include <fsio.h>
  25. #include <fsrmt.h>
  26. #include <fsioFile.h>
  27. #include <fsioDevice.h>
  28. #include <fsioPipe.h>
  29. #include <fsNameOps.h>
  30. #include <fsrmtInt.h>
  31.  
  32. /*
  33.  * fs_DomainLookup for FS_REMOTE_SPRITE_DOMAIN type.
  34.  */
  35.  
  36. static Fs_DomainLookupOps rmtDomainLookup = {
  37.      FsrmtImport, Fsio_NoProc, FsrmtOpen, FsrmtGetAttrPath,
  38.      FsrmtSetAttrPath, FsrmtMakeDevice, FsrmtMakeDir, 
  39.      FsrmtRemove, FsrmtRemoveDir, FsrmtRename, FsrmtHardLink
  40. };
  41.  
  42. /*
  43.  * Domain specific get/set attributes table.  These routines are used
  44.  * to get/set attributes on the name server given a fileID (not a pathname).
  45.  */
  46. static Fs_AttrOps rmtAttrOpTable =   { FsrmtGetAttr, FsrmtSetAttr };
  47.  
  48.  
  49. /*
  50.  * File stream type ops for FSIO_RMT_FILE_STREAM, FSIO_RMT_DEVICE_STREAM,
  51.  * and FSIO_RMT_PIPE_STREAM;
  52.  */
  53.  
  54. static Fsio_StreamTypeOps rmtFileStreamOps[] = {
  55. /*
  56.  * Remote file stream.  The file is at a remote server but blocks might 
  57.  * be cached in the block cache.
  58.  */
  59.     { FSIO_RMT_FILE_STREAM, FsrmtFileIoOpen, FsrmtFileRead, FsrmtFileWrite,
  60.         FsrmtFilePageRead, FsrmtFilePageWrite,
  61.         Fsrmt_BlockCopy,
  62.         FsrmtFileIOControl, Fsio_FileSelect,
  63.         FsrmtFileGetIOAttr, FsrmtFileSetIOAttr,
  64.         FsrmtFileVerify, FsrmtFileMigClose, FsrmtFileMigOpen,
  65.         FsrmtFileMigrate, FsrmtFileReopen,
  66.         FsrmtFileScavenge,
  67.         Fsio_NullClientKill, FsrmtFileClose},
  68. /*
  69.  * Remote device stream.  Forward the operations to the remote I/O server.
  70.  */
  71.     { FSIO_RMT_DEVICE_STREAM, FsrmtDeviceIoOpen, Fsrmt_Read, Fsrmt_Write,
  72.         Fsio_NoProc, Fsio_NoProc, Fsio_NoProc,     /* Paging routines */
  73.         Fsrmt_IOControl, Fsrmt_Select,
  74.         Fsrmt_GetIOAttr, Fsrmt_SetIOAttr,
  75.         FsrmtDeviceVerify, Fsrmt_IOMigClose, Fsrmt_IOMigOpen,
  76.         FsrmtDeviceMigrate, FsrmtDeviceReopen,
  77.         Fsutil_RemoteHandleScavenge, Fsio_NullClientKill, Fsrmt_IOClose},
  78.  /*
  79.   * Remote anonymous pipe stream.  These arise because of migration.
  80.   */
  81.     { FSIO_RMT_PIPE_STREAM, Fsio_NoProc, Fsrmt_Read, Fsrmt_Write,
  82.         Fsio_NoProc, Fsio_NoProc, Fsio_NoProc,     /* Paging routines */
  83.         Fsrmt_IOControl, Fsrmt_Select,
  84.         Fsrmt_GetIOAttr, Fsrmt_SetIOAttr,
  85.         FsrmtPipeVerify, Fsrmt_IOMigClose, Fsrmt_IOMigOpen,
  86.         FsrmtPipeMigrate, FsrmtPipeReopen,
  87.         Fsutil_RemoteHandleScavenge, Fsio_NullClientKill, Fsrmt_IOClose},
  88. };
  89.  
  90. static int numRmtFileStreamOps = sizeof(rmtFileStreamOps)/
  91.                  sizeof(rmtFileStreamOps[0]);
  92.  
  93. /*
  94.  *----------------------------------------------------------------------
  95.  *
  96.  * Fsrmt_InitializeOps --
  97.  *
  98.  *    Initialize the fsOpTable switch for the remote domain naming 
  99.  *    and remote domain streams.
  100.  *
  101.  * Results:
  102.  *    None.
  103.  *
  104.  * Side effects:
  105.  *    None.
  106.  *
  107.  *----------------------------------------------------------------------
  108.  */
  109.  
  110. void
  111. Fsrmt_InitializeOps()
  112. {
  113.     int    i;
  114.  
  115.     Fs_InstallDomainLookupOps(FS_REMOTE_SPRITE_DOMAIN, &rmtDomainLookup, 
  116.                 &rmtAttrOpTable );
  117.     for (i = 0; i < numRmtFileStreamOps; i++)  { 
  118.     Fsio_InstallStreamOps(rmtFileStreamOps[i].type, &(rmtFileStreamOps[i]));
  119.     }
  120.  
  121. }
  122.  
  123. /*
  124.  *----------------------------------------------------------------------
  125.  *
  126.  * Fsrmt_Bin() --
  127.  *
  128.  *    Setup objects to be binned.
  129.  *
  130.  * Results:
  131.  *    None.
  132.  *
  133.  * Side effects:
  134.  *    None.
  135.  *
  136.  *----------------------------------------------------------------------
  137.  */
  138.  
  139. void
  140. Fsrmt_Bin()
  141. {
  142.     Mem_Bin(sizeof(Fsrmt_FileIOHandle));
  143. }
  144.  
  145.  
  146. /*
  147.  *----------------------------------------------------------------------
  148.  *
  149.  * Fsio_FileRecovTestUseCount --
  150.  *
  151.  *      For recovery testing, return the use count on the file's io handle.
  152.  *
  153.  * Results:
  154.  *      Use count.
  155.  *
  156.  * Side effects:
  157.  *      None.
  158.  *
  159.  *----------------------------------------------------------------------
  160.  */
  161. int
  162. Fsrmt_FileRecovTestUseCount(handlePtr)
  163.     Fsrmt_FileIOHandle   *handlePtr;
  164. {
  165.     return handlePtr->rmt.recovery.use.ref;
  166. }
  167.  
  168.  
  169. /*
  170.  *----------------------------------------------------------------------
  171.  *
  172.  * Fsio_FileRecovTestNumCacheBlocks --
  173.  *
  174.  *      For recovery testing, return the number of blocks in the cache
  175.  *      for this file.
  176.  *
  177.  * Results:
  178.  *      Number of blocks.
  179.  *
  180.  * Side effects:
  181.  *      None.
  182.  *
  183.  *----------------------------------------------------------------------
  184.  */
  185. int
  186. Fsrmt_FileRecovTestNumCacheBlocks(handlePtr)
  187.     Fsrmt_FileIOHandle   *handlePtr;
  188. {
  189.     return handlePtr->cacheInfo.blocksInCache;
  190. }
  191.  
  192.  
  193. /*
  194.  *----------------------------------------------------------------------
  195.  *
  196.  * Fsio_FileRecovTestNumDirtyCacheBlocks --
  197.  *
  198.  *      For recovery testing, return the number of dirty blocks in the cache
  199.  *      for this file.
  200.  *
  201.  * Results:
  202.  *      Number of dirty blocks.
  203.  *
  204.  * Side effects:
  205.  *      None.
  206.  *
  207.  *----------------------------------------------------------------------
  208.  */
  209. int
  210. Fsrmt_FileRecovTestNumDirtyCacheBlocks(handlePtr)
  211.     Fsrmt_FileIOHandle   *handlePtr;
  212. {
  213.     return handlePtr->cacheInfo.numDirtyBlocks;
  214. }
  215.  
  216.  
  217.